package cn.hchaojie.camp.day05.oop;

public class DemoRunnable {
	public static void main(String[] args) {
		// 断点 debug
		Runnable runnable = new StarPrinter();	// 多态的方式定义一个引用

		// Runnable封装了任务的实现细节
		
		Thread thread = new Thread(runnable);	// 创建一个线程
		thread.start();		// 启动线程
	}
}

// runnalbe接口的run方法作用：指定线程作什么后台任务

class StarPrinter implements Runnable {
	
	@Override
	public void run() {
		for (int y = 2; y >= -2; y--) {
			for (int x = -2; x <= 2; x++) {
				if (x == y || x == -y) {
					System.out.print(" *");
				} else {
					System.out.print(" .");
				}
			}
			
			System.out.println();
		}
	}
}
